package com.example.verification.utils;

import java.io.Serializable;
import java.util.List;

public class PageData<T> implements Serializable {
	
	/**
	 * 本类用作对page数据进行格式化为Jqgrid数据类型
	 */
	
	private static final long serialVersionUID = -5395997221963176643L;
	
	private List<T> rows;				// list result of this page
	private int page;				// 当前页码
	private int pageSize;				// 单页显示数
	private int total; //总页数
	private int records;				 // 总数据量
	
	public PageData(List<T> list, int page, int pageSize, int records){
		this.rows = list;
		this.page = page;
		this.pageSize = pageSize;
		this.records = records;
		if (records%pageSize == 0) {
			this.total = records/pageSize;
		}else {
			this.total = records/pageSize + 1;
		}
	}
	
	public boolean isFirstPage() {
		return page == 1;
	}
	
	public boolean isLastPage() {
		return page >= total;
	}
	
	public PageData() {
		
	}

	public List<T> getRows() {
		return rows;
	}

	public void setRows(List<T> rows) {
		this.rows = rows;
	}

//	public int getPageSize() {
//		return pageSize;
//	}
//
//	public void setPageSize(int pageSize) {
//		this.pageSize = pageSize;
//	}

	public int getTotal() {
		return total;
	}

	public void setTotal(int total) {
		this.total = total;
	}

	public int getRecords() {
		return records;
	}

	public void setRecords(int records) {
		this.records = records;
	}
	
}

